package com.hm.handler.request.hand;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;

import com.hm.common.annotation.AuthenticationAnnotation;

/**
 * @author shishun.wang
 * @date 2016年5月23日 上午7:50:14
 * @version 1.0
 * @describe
 */
@Component
public class AuthenticationHandler {

//	@Autowired
//	protected RedisStringValueUtil redisStringValueUtil;

	public boolean handler(HttpServletRequest request, HttpServletResponse response, HandlerMethod method)
			throws Exception {
		AuthenticationAnnotation authentication = method.getMethod().getAnnotation(AuthenticationAnnotation.class);
		if (null != authentication) {
			return authenticationCheck(request, response);
		}
		return true;
	}

	private boolean authenticationCheck(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		//String authorizationToken = request.getHeader(CommonDef.BaseInit.SessionOrCookieToken.CLIENT_ACCREDIT_TOKEN);
//		String authorizationToken = "57796020190b3923b973b4a7";
//		if(null != authorizationToken){
//			if(null != redisStringValueUtil.get(authorizationToken)){
//				
//			}else{
//				return responseUtil.sendError(ResponseState.SESSION_TIMEOUT, response);
//			}
//		}else{
//			return responseUtil.sendError(HttpServletResponse.SC_FORBIDDEN, response);
//		}
		return true;
	}
	
}
